//
//  newestOtherCell.m
//  A Learning Walk
//
//  Created by dllo on 16/6/16.
//  Copyright © 2016年 战斗民族. All rights reserved.
//

#import "newestOtherCell.h"

@interface newestOtherCell ()
@property(nonatomic, retain)UILabel *titleLabel;
@property(nonatomic, retain)UIImageView *imageOne;
@property(nonatomic, retain)UIImageView *imageTwo;
@property(nonatomic, retain)UIImageView *imageThree;
@property(nonatomic, retain)UILabel *timeLabel;
@property(nonatomic, retain)UILabel *replyLabel;
@end

@implementation newestOtherCell

-(void)dealloc{
    [_newsestmodel release];
    [_Model release];
    [_titleLabel release];
    [_timeLabel release];
    [_imageOne release];
    [_imageTwo release];
    [_imageThree release];
    [_replyLabel release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

-(void)createSubviews{
    self.imageOne = [UIImageView new];
    self.imageOne.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.imageOne];
    
    self.imageTwo = [UIImageView new];
    self.imageTwo.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.imageTwo];
    
    self.imageThree = [UIImageView new];
    self.imageThree.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.imageThree];
    
    
    self.timeLabel = [UILabel new];
    self.timeLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.timeLabel];
    
    self.titleLabel = [UILabel new];
    self.titleLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.font = [UIFont systemFontOfSize:20];
    
    self.replyLabel = [UILabel new];
    self.replyLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.replyLabel];
    
    self.myView = [UIView new];
    self.myView.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.myView];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_equalTo(10);
        make.right.mas_equalTo(-20);
        make.height.mas_equalTo(30);
      
    }];
    [self.imageOne mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.height.mas_equalTo(70);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10);
    }];
    [self.imageTwo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.imageOne.mas_right).offset(10);
        make.height.mas_equalTo(self.imageOne);
        make.width.mas_equalTo(self.imageOne);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10);
    }];
    [self.imageThree mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.imageTwo.mas_right).offset(10);
        make.height.mas_equalTo(self.imageTwo);
        make.width.mas_equalTo(self.imageTwo);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10);
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.imageOne.mas_bottom).offset(10);
        make.left.mas_equalTo(self.titleLabel);
        make.height.equalTo(@25);
        make.width.mas_equalTo(self.contentView.frame.size.width / 3);
        
    }];
    
    [self.replyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.timeLabel);
        make.height.equalTo(self.timeLabel);
        make.right.equalTo(@(-15));
    }];
    [self.myView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-1);
        make.left.mas_equalTo(self.titleLabel);
        make.right.mas_equalTo(-10);
        make.height.mas_equalTo(1);
    }];
    
}

-(void)setNewsestmodel:(newestModel *)newsestmodel{
    _newsestmodel = newsestmodel;
    self.titleLabel.text = _newsestmodel.title;
    self.timeLabel.text = _newsestmodel.time;
    self.replyLabel.text = [[NSString stringWithFormat:@"%ld",(long)_newsestmodel.replycount] stringByAppendingString:@"图片"];
    NSString *str = [_newsestmodel.indexdetail substringFromIndex:11];
    NSArray *array = [str componentsSeparatedByString:@","];
    [self.imageOne sd_setImageWithURL:[NSURL URLWithString:array[0]] placeholderImage:[UIImage imageNamed:@"NOImage"]];
    [self.imageTwo sd_setImageWithURL:[NSURL URLWithString:array[1]] placeholderImage:[UIImage imageNamed:@"NOImage"]];
    [self.imageThree sd_setImageWithURL:[NSURL URLWithString:array[2]] placeholderImage:[UIImage imageNamed:@"NOImage"]];
}

-(void)setModel:(newsModel *)Model{
    _Model = Model;
    self.titleLabel.text = _Model.title;
    self.timeLabel.text = _Model.time;
    self.replyLabel.text = [[NSString stringWithFormat:@"%ld",(long)_Model.replycount] stringByAppendingString:@"评论"];
    NSString *str = _Model.indexdetail;
    NSArray *array = [str componentsSeparatedByString:@"㊣"];
    [self.imageOne sd_setImageWithURL:[NSURL URLWithString:array[0]] placeholderImage:[UIImage imageNamed:@"NOImage"]];
    [self.imageTwo sd_setImageWithURL:[NSURL URLWithString:array[1]] placeholderImage:[UIImage imageNamed:@"NOImage"]];
    [self.imageThree sd_setImageWithURL:[NSURL URLWithString:array[2]] placeholderImage:[UIImage imageNamed:@"NOImage"]];
}

-(void)setCarmodel:(carsModel *)carmodel{
    _carmodel = carmodel;
    self.titleLabel.text = _carmodel.title;
    self.timeLabel.text = _carmodel.time;
    self.replyLabel.text = [[NSString stringWithFormat:@"%ld",(long)_carmodel.replycount] stringByAppendingString:@"评论"];
    NSString *str = _carmodel.indexdetail;
    NSArray *array = [str componentsSeparatedByString:@"㊣"];
    [self.imageOne sd_setImageWithURL:[NSURL URLWithString:array[0]] placeholderImage:[UIImage imageNamed:@"NOImage"]];
    [self.imageTwo sd_setImageWithURL:[NSURL URLWithString:array[1]] placeholderImage:[UIImage imageNamed:@"NOImage"]];
    [self.imageThree sd_setImageWithURL:[NSURL URLWithString:array[2]] placeholderImage:[UIImage imageNamed:@"NOImage"]];
}






@end
